package com.tjzx.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Property;

import com.tjzx.common.Pager;
import com.tjzx.dao.EipProductTypeDAO;
import com.tjzx.entity.EipProductType;

public class EipProductTypeService {
	private EipProductTypeDAO eipProductTypeDAO;

	public EipProductTypeDAO getEipProductTypeDAO() {
		return eipProductTypeDAO;
	}

	public void setEipProductTypeDAO(EipProductTypeDAO eipProductTypeDAO) {
		this.eipProductTypeDAO = eipProductTypeDAO;
	}
	
	public EipProductType getProductTypeById(java.lang.Integer id) {
		return eipProductTypeDAO.findById(id);
	}
	public Pager<EipProductType> getTCNews(int pageNo, int pageSize, int firstResult, int maxResults) {
		DetachedCriteria criteria = DetachedCriteria.forClass(EipProductType.class);
		criteria.add(Property.forName("pid").eq(125));

		int rowCount = eipProductTypeDAO.getCount(criteria);
		criteria.addOrder(Property.forName("ptid").desc());
		
		List list = eipProductTypeDAO.findByCriteria(criteria, firstResult, maxResults);
		return new Pager<EipProductType>(pageNo, pageSize, rowCount, list);
	}
}
